﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Editor;
using ESRI.ArcGIS.EditorExt;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.GlobeCore;
using ESRI.ArcGIS.NetworkAnalysis;
using ESRI.ArcGIS.Output;
using ESRI.ArcGIS.SystemUI;
using DIWAGIS.Class;
using DIWAGIS.Modules;

namespace DIWAGIS.ApplicationLayer.QuanLyMangCapNuoc
{
    public partial class frmOngTruyenDan : Form
    {
        public frmOngTruyenDan()
        {
            InitializeComponent();
        }
        public frmOngTruyenDan(IFeature feature)
            {
                    _pFeature = feature;
            }
         public IFeature _pFeature;
        string sTableName = generalVariable.database + "." + generalVariable.schema + "." + ClassVariables.wOngTruyenDan;

        private void frmOngTruyenDan_Load(object sender, EventArgs e)
        {
            DIWAGIS.Module.WorkingWithDomain cbx = new DIWAGIS.Module.WorkingWithDomain();
       /*     cbx.loadDataDomainToCombobox(VatLieu, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMVatLieuOngNuoc");
            cbx.LoadSubTypeToCombobox(CoOng, sTableName, "CoOng", DIWAGIS.Modules.generalVariable.ICurrentWorkspace);
            cbx.loadDataDomainToCombobox(TieuChuan, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMTieuChuanOngNuoc");
            cbx.loadDataDomainToCombobox(Hieu, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMHieuOngNuoc");
            cbx.loadDataDomainToCombobox(TinhTrang, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMTinhTrangOngNuoc");
            //cbx.loadDataDomainToCombobox(CapOng, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMCapOng");
            cbx.loadDataDomainToCombobox(LoaiOngNuoc, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMLoaiOngNuoc");
            cbx.loadDataDomainToCombobox(HuongDongChay, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMHuongDongChay");
            cbx.loadDataDomainToCombobox(NuocSanXuat, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMNuocSanXuatOngNuoc");
*/
            cbx.loadDataDomainToCombobox(HuongDongChay, DIWAGIS.Modules.generalVariable.ICurrentWorkspace, "DMHuongDongChay");
            SqlCommand sqlcommand = new SqlCommand();

/*
            sqlcommand.CommandText = "SELECT TENCONDUONG,IDCONDUONG FROM " + generalVariable.database + "." + generalVariable.schema + "." + " CONDUONG ";
            cbx.loadDataToCombobox(MaDuong, sqlcommand);*/

            DIWAGIS.Class.general_Model p = new DIWAGIS.Class.general_Model();
            p.loadDataIntoForm(this, _pFeature);
        }

        private void buttonLuu_Click(object sender, EventArgs e)
        {
            IWorkspaceEdit pWorkSpaceEdit;
            pWorkSpaceEdit = generalVariable.ICurrentWorkspace as IWorkspaceEdit;
            pWorkSpaceEdit.StartEditing(true);
            pWorkSpaceEdit.StartEditOperation();

            DIWAGIS.Class.general_Model p = new DIWAGIS.Class.general_Model();
            p.setDataIntoDatatable(this, _pFeature);

            _pFeature.Store();
            pWorkSpaceEdit.StopEditOperation();
            pWorkSpaceEdit.StopEditing(true);
            pWorkSpaceEdit = null;
            MessageBox.Show("Cập nhật thành công", generalVariable.nameProgram, MessageBoxButtons.OK);
            this.Close();
        }

        private void buttonDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }
       
        
    }
}
